<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showbook.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <a href="/bookshopping/login.jsp">请登入</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/bookshopping/viewcar.jsp">查看购物车</a>
<hr/>

	<table border="1px" width="80%"align="center" cellspacing="2px" cellpadding="2px">
		<tr>
			<th colspan="5"align="center">书本信息</tr>
		<tr>
			<th>书名</th>
			<th>作者</th>
			<th>出版社</th>
			<th>价格</th>
			<th>操作</th>
		</tr >
	<c:forEach items="${bp.books}" var="book">
		<tr align="center">
			<td>${book.name}</td>
			<td>${book.author}</td>
			<td>${book.publish}</td>
			<td>${book.price}</td>
			<td><a href="${pageContext.request.contextPath}/servlet/BuyServlet?id=${book.id}&currentPage=${bp.currentPage}">购买</a></td>
		</tr>
	</c:forEach>
	<tr>
		<td colspan="5" align="center">
		<a href="${pageContext.request.contextPath}/servlet/PageServlet?currentPage=0">首页</a>
		<c:choose>
			<c:when test="${bp.currentPage>0}">
					<a href="${pageContext.request.contextPath}/servlet/PageServlet?currentPage=${bp.currentPage-1}">上一页</a>
			</c:when>
			<c:otherwise>
			  上一页
			</c:otherwise>
		</c:choose>
		当前:【第${bp.currentPage + 1}页，共${bp.totalPage}页】
		<c:choose>
			<c:when test="${bp.currentPage<bp.totalPage-1}">
				<a href="${pageContext.request.contextPath}/servlet/PageServlet?currentPage=${bp.currentPage+1}">下一页</a>
			</c:when>
			<c:otherwise>
			  下一页
			</c:otherwise>
		</c:choose>
		<a href="${pageContext.request.contextPath}/servlet/PageServlet?currentPage=${bp.totalPage-1}">末页</a>
		</td>
	</tr>
	</table>
  </body>
</html>
